<template>
  <div class="interaction-start">
    <div class="container">
      <div class="box-left">
        <div class="section">
          <div class="case-tip">
            <div class="case-tipName">{{cases.resourceCaseName}}</div>
            <div class="sm-group">
              <el-button type="text" size="mini" icon="el-icon-s-custom">{{cases.resourceGroupName}}</el-button>
              <el-button type="text" size="mini" icon="el-icon-s-grid">{{cases.nodeNum}}个环节</el-button>
            </div>
          </div>
          <!--<div class="train-info">-->
          <!--当前得分：87 排名：第五名-->
          <!--</div>-->
          <div class="case-con">{{cases.caseRequestEn}}</div>
        </div>
        <div class="section">
          <div class="case-tip">实训小组</div>
          <div class="list-box">
            <el-collapse>
              <el-collapse-item :title="item.stuGroupName" v-for="(item, index) in comments.personScoreList" :key="index">
                <ul>
                  <li v-for="(it, id) in item.stuInfoList" :key="id" class="cursor" @click="personScore(it)">
                    <div class="personal-logo">
                      <img :src="it.headImgUrl" alt="">
                      <div>{{it.name}}</div>
                      <el-tag type="success" v-if="it.isHeadman === '1'">组长</el-tag>
                    </div>
                    <div>{{it.score}}分</div>
                  </li>
                </ul>
              </el-collapse-item>
            </el-collapse>
          </div>
        </div>
      </div>
      <div class="box-right">
        <!-- 案例背景 -->
        <div class="case-tip">对其评分的学生</div>
        <div class="list-box">
          <ul>
            <li v-for="(it, id) in stuPersonScoreList" :key="id" :class="{'cursor': it.isScore === '1'}" @click="personScoreDetail(it)">
              <div class="personal-logo">
                <img :src="it.headImgUrl" alt="">
                <div>{{it.stuName}}</div>
              </div>
              <div v-if="it.isScore === '1'">{{it.totalScore}}分</div>
              <div v-else>未评分</div>
            </li>
          </ul>
        </div>
        <div class="case-tip" v-if="personScoreDetails.scoreDetail.length > 0">评分详情</div>
        <!-- 评分详情 -->
        <div class="score-box" v-for="(item, index) in personScoreDetails.scoreDetail" :key="index">
          <div class="score-key">{{item.evaluateItem}}</div>
          <el-tooltip class="score-value" :content="item.evaluateItemRemark" placement="top">
            <div>
              {{item.evaluateItemScore}}分
              <i class="el-icon-success"></i>
            </div>
          </el-tooltip>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { trainingInteraction, personScoreList, personScore, personScoreDetail } from '@/api/teacher/manage/trainingInteractionManage'
export default {
  name: 'interactionCommentPersonal',
  data () {
    return {
      resourceCaseId: this.$route.query.id,
      cases: {
        nodeNum: '',
        resourceCaseId: '',
        resourceCaseName: '',
        resourceGroupName: '',
        caseRequestCn: '',
        caseRequestEn: '',
        resourceCaseBgList: [],
        finishedFlag: '',
        lessonICaseId: '',
        classNames: '',
        currentCaseNodeName: '',
        isGroup: '',
        stuNo: ''
      },
      comments: {
        resourceCaseId: '',
        resourceCaseName: '',
        caseRequestCn: '',
        caseRequestEn: '',
        resourceCaseBgList: [],
        caseNodeName: '',
        lessonICaseId: '',
        personScoreList: []
      },
      stuPersonScoreList: [],
      personScoreDetails: {
        lessonICaseId: '',
        scoreDetail: [],
        totalScore: ''
      }
    }
  },
  mounted () {
    this.trainingInteraction()
  },
  methods: {
    async trainingInteraction () {
      const res = await trainingInteraction({ resourceCaseId: this.resourceCaseId })
      if (res.code === '200') {
        this.cases = res.data
        this.personScoreList()
      } else {
        this.$message.error(res.message)
      }
    },
    async personScoreList () {
      const res = await personScoreList({
        lessonICaseId: this.cases.lessonICaseId,
        resourceCaseId: this.resourceCaseId
      })
      if (res.code === '200') {
        this.comments = res.data
        this.comments.personScoreList = this.comments.personScoreList ? JSON.parse(this.comments.personScoreList) : []
      } else {
        this.$message.error(res.message)
      }
    },
    async personScore (item) {
      const res = await personScore({
        lessonICaseId: this.cases.lessonICaseId,
        stuId: item.stuId,
        headImgUrl: item.headImgUrl,
        name: item.name
      })
      if (res.code === '200') {
        this.stuPersonScoreList = res.data.stuPersonScoreList
      } else {
        this.$message.error(res.message)
      }
    },
    async personScoreDetail (item) {
      if (item.isScore === '0') {
        return
      }
      const res = await personScoreDetail({ personScoreId: item.personScoreId })
      if (res.code === '200') {
        this.personScoreDetails = res.data
      } else {
        this.$message.error(res.message)
      }
    }
  }
}
</script>
<style scoped lang="scss" rel="stylesheet/scss">
  .interaction-start {
    .container {
      display: flex;
      justify-content: space-between;
      .box-left {
        width: 550px;
        background: #fff;
        padding: 15px;
        .section {
          .sm-group{
            margin-top: 10px;
          }
          .train-info {
            color: #BBBBBB;
            font-size: 14px;
            margin-top: 10px;
          }
          .content {
            color: #BBBBBB;
            font-size: 14px;
            padding:20px 0;
            line-height: 1.2;
          }
          .card {
            border-radius: 20px;
            background: #f5f5f5;
            width: 455px;
            margin: 0 auto;
            .row {
              display: flex;
              align-items: center;
              justify-content: space-between;
            }
            .row-1{
              padding: 0 20px;
              line-height: 60px;
              border-bottom: 1px solid #D2D2D2;
            }
            .row-2{
              padding: 0 60px;
              line-height: 50px;
            }
          }
        }
      }
      .box-right {
        width: 630px;
        min-height: 100%;
        background: #fff;
        padding: 15px;
        box-sizing: border-box;
        .title {
          font-size: 14px;
          font-weight: bold;
          position: relative;
          display: flex;
          align-items: center;
          justify-content: space-between;
          .tab {
            display: flex;
            .tab-item {
              width: 85px;
              line-height: 40px;
              border: 1px solid #D9D9D9;
              text-align: center;
              font-weight: initial;
              cursor: pointer;
              &.active {
                border: 1px solid #828282;
              }
            }
          }
          .time {
            font-size: 14px;
            color: #828282;
            position: absolute;
            right: 0;
            font-weight: normal;
          }
        }
        .content {
          color:#BBBBBB;
          font-size: 14px;
          padding:20px 0;
          line-height: 1.2;
        }
        .media-box {
          padding: 15px 0;
          .video {
            width: 100%;
          }
        }
        .file-box {
          line-height: 40px;
          display: flex;
          justify-content: space-between;
          border-bottom: 1px solid #f5f5f5;
          font-size: 14px;
          font-weight: bold;
          a {
            color: #009cf6;
            font-weight: normal;
          }
        }
        .fill-box {
          .fill-title {
            font-size: 14px;
          }
          textarea {
            width: 100%;
            margin-top: 20px;
          }
        }
        .report-box {
          li {
            line-height: 70px;
            position: relative;
            .right-arrow {
              position: absolute;
              right: 0;
            }
            textarea {
              width: 100%;
              margin-top: 20px;
            }
          }
        }
        .wait-btn, .submit-btn {
          width: 100%;
          line-height: 40px;
          border-radius: 10px;
          background: #BBBBBB;
          color: #fff;
          text-align: center;
          margin-top: 30px;
          cursor: pointer;
        }
      }
    }
  }
  .personal-logo{
    display: flex;
    align-items: center;
    img {
      width: 30px;
      height: 30px;
      margin-right: 10px;
    }
  }
  .list-box {
    margin-top: 20px;
    ul {
      li {
        display: flex;
        justify-content: space-between;
        line-height: 60px;
        font-size: 14px;
        border-bottom: 1px solid #f5f5f5;
        padding: 0 10px;
        position: relative;
        i{
          margin-left: 10px;
        }
        &:hover {
          background: #f5f5f5;
        }
        &.cursor {
          cursor: pointer;
        }
        .right-arrow {
          position: absolute;
          right: 10px;
        }
      }
    }
  }
</style>
